{{ header }}
<script>
	!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
		n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
		n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
		t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
		document,'script','https://connect.facebook.net/en_US/fbevents.js');
		    {% for option in jan %}
			   fbq('init', {{ option }});
		    {% endfor %}
			
			fbq('track', "PageView");
	fbq('track', "ViewContent");
</script>
<div id="product-product" class="container">
    <div id="content">
        {#提示框#}
        <div id="tipModule"></div>
        {#蒙板#}
        <div class="mask"></div>
        {#商品詳情#}
        <div class="product-content">
            {#商品规格页面#}
            <div id="product">
                <input type="hidden" name="product_id" value="{{ product_id }}"/>
                <input type="hidden" name="quantity" value="{{ minimum }}"/>
                {#头部#}
                <div class="product-header">
                    <i class="iconfont icon-flow" id="closeProduct"></i>
                    <span>{{ text_attrtitle }}</span>
                </div>
                {% if options %}
                    <div class="product-option">
                        {% set item = 0 %}
                        {% for option in options %}
                            {% set item = item + 1 %}
                            {% if option.type == 'select' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <select name="option[{{ option.product_option_id }}]"
                                            id="input-option{{ option.product_option_id }}" class="form-control">
                                        <option value="">{{ text_select }}</option>
                                        {% for option_value in option.product_option_value %}
                                            <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }}
                                                {% if option_value.price %}
                                                    ({{ option_value.price_prefix }}{{ option_value.price }})
                                                {% endif %} </option>
                                        {% endfor %}
                                    </select>
                                </div>
                            {% endif %}
                            {% if option.type == 'radio' %}
                                <div class="newRadio form-group">
                                    <label class="control-label optionName">{{ option.name }}:<span class="selecting"></span></label>
                                    <div class="radio-box" id="input-option{{ option.product_option_id }}">
                                        {% for option_value in option.product_option_value %}
                                            {% if option_value.image %}
                                                <div data-name="{{ option.name }}" class="img-radio" {% if option_value.price %} data-changenum="{{ option_value.price }}" data-changetype="{{ option_value.price_prefix }}"{% else %} data-changenum="0" data-changetype="+"{% endif %}>
                                                    <label>
                                                        <input type="radio"
                                                               name="option[{{ option.product_option_id }}]"
                                                               value="{{ option_value.product_option_value_id }}"/>
                                                        <img src="{{ option_value.image }}"
                                                             alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}"
                                                             class="img-thumbnail"/>
                                                        <div class="option-name" style="display: none">{{ option_value.name }}</div>
                                                    </label>
                                                </div>
                                            {% else %}
                                                <div {% if item == 1 %} data-isfirst="1" {% endif %} data-name="{{ option.name }}" class="radio" {% if option_value.price %} data-changenum="{{ option_value.price }}" data-changetype="{{ option_value.price_prefix }}"{% else %} data-changenum="0" data-changetype="+"{% endif %}>
                                                    <label>
                                                        <input type="radio"
                                                               name="option[{{ option.product_option_id }}]"
                                                               value="{{ option_value.product_option_value_id }}"/>
                                                        <div class="option-name">{{ option_value.name }}</div>
                                                            {#{% if option_value.price %}({{ option_value.price_prefix }}{{ option_value.price }}){% endif %}#}
                                                    </label>
                                                </div>
                                            {% endif %}
                                        {% endfor %}
                                    </div>
                                </div>
                                {#{% if item == 1 %}#}
                                    {#<div class="attr-title">{{ heading_title }}</div>#}
                                {#{% endif %}#}
                            {% endif %}
                            {% if option.type == 'checkbox' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label">{{ option.name }}</label>
                                    <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
                                            <div class="checkbox">
                                                <label>
                                                    <input type="checkbox"
                                                           name="option[{{ option.product_option_id }}][]"
                                                           value="{{ option_value.product_option_value_id }}"/>
                                                    {% if option_value.image %} <img src="{{ option_value.image }}"
                                                                                     alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}"
                                                                                     class="img-thumbnail"/> {% endif %}
                                                    {{ option_value.name }}
                                                    {% if option_value.price %}
                                                        ({{ option_value.price_prefix }}{{ option_value.price }})
                                                    {% endif %} </label>
                                            </div>
                                        {% endfor %} </div>
                                </div>
                            {% endif %}
                            {% if option.type == 'text' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <input type="text" name="option[{{ option.product_option_id }}]"
                                           value="{{ option.value }}" placeholder="{{ option.name }}"
                                           id="input-option{{ option.product_option_id }}" class="form-control"/>
                                </div>
                            {% endif %}
                            {% if option.type == 'textarea' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <textarea name="option[{{ option.product_option_id }}]" rows="5"
                                              placeholder="{{ option.name }}"
                                              id="input-option{{ option.product_option_id }}"
                                              class="form-control">{{ option.value }}</textarea>
                                </div>
                            {% endif %}
                            {% if option.type == 'file' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label">{{ option.name }}</label>
                                    <button type="button" id="button-upload{{ option.product_option_id }}"
                                            data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i
                                                class="fa fa-upload"></i> {{ button_upload }}</button>
                                    <input type="hidden" name="option[{{ option.product_option_id }}]" value=""
                                           id="input-option{{ option.product_option_id }}"/>
                                </div>
                            {% endif %}
                            {% if option.type == 'date' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <div class="input-group date">
                                        <input type="text" name="option[{{ option.product_option_id }}]"
                                               value="{{ option.value }}" data-date-format="YYYY-MM-DD"
                                               id="input-option{{ option.product_option_id }}" class="form-control"/>
                                        <span class="input-group-btn">
            <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
            </span></div>
                                </div>
                            {% endif %}
                            {% if option.type == 'datetime' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <div class="input-group datetime">
                                        <input type="text" name="option[{{ option.product_option_id }}]"
                                               value="{{ option.value }}" data-date-format="YYYY-MM-DD HH:mm"
                                               id="input-option{{ option.product_option_id }}" class="form-control"/>
                                        <span class="input-group-btn">
            <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
            </span></div>
                                </div>
                            {% endif %}
                            {% if option.type == 'time' %}
                                <div class="form-group{% if option.required %} required {% endif %}">
                                    <label class="control-label"
                                           for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                                    <div class="input-group time">
                                        <input type="text" name="option[{{ option.product_option_id }}]"
                                               value="{{ option.value }}" data-date-format="HH:mm"
                                               id="input-option{{ option.product_option_id }}" class="form-control"/>
                                        <span class="input-group-btn">
            <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
            </span></div>
                                </div>
                            {% endif %}
                        {% endfor %}
                    </div>
                {% endif %}
                <div class="form-group buy-count">
                    <label class="control-label" for="input-quantity">{{ entry_qty }}:</label>
                    <div style="display: flex;justify-content: space-between;align-items: center;">
                        <div class="change-number">
                            <i class="iconfont icon-jian" id="minus"></i>
                            <input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity" disabled/>
                            <i class="iconfont icon-jia" id="plus"></i>
                            <input type="hidden" name="product_id" value="{{ product_id }}"/>
                        </div>
                        <button type="button" class="toCart" id="toCart">{{ text_tocartbtn }}</button>
                    </div>
                </div>
            </div>
            {#购物车页面#}
            <div id="productOrder">

                <div class="order-header">
                    <span id="backHome">
                        <i class="iconfont icon-flow" id="closeProduct"></i>
                        <span style="padding-left: 5px;">{{ text_payback }}</span>
                    </span>
                </div>
                <div class="top-tip">
                    <div class="tip-title">Order Confirm</div>
                    <div class="tip-content">Tips: Support cash on delivery+ Free shipping+ Seven days after-sales service. If you have any questions, please send email to Or our aftersales email on the courier receipt. Please remember to attach your name and order number in the message. We will reply you as soon as possible! Wish you a happy shopping!</div>
                    <div class="tip-foot">Please fill in the valid and correct phone number, the customer service staff will contact with you soon.</div>
                </div>
                {#購物車#}
                <div id="scrollBuy">
                    <div class="panel-collapse" id="collapse-payment-address">
                        {{ guesthtml }}
                    </div>
                </div>
                {#订单详情#}
                <div class="confirm-order">
                    <div class="show-order">
                        <div class="show-order-left">
                            <img class="orderImg" src="" alt="">
                        </div>
                        <div class="show-order-right">
                            <div class="orderName">{{ heading_title }}</div>
                            <div class="orderMeal"></div>
                            <div class="orderCount">
                                <div class="orderAttr"></div>
                                <div>{{ text_allnum }}<span id="countNumber"></span></div>
                            </div>
                        </div>
                    </div>
                    <div class="hide-order" style="display: none">
                        <div class="hide-order-left">
                            <img class="orderImg" src="" alt="">
                        </div>
                        <div class="hide-order-right">
                            <div class="orderName">{{ heading_title }}</div>
                            <div class="orderAttr"></div>
                        </div>
                    </div>
                    <div class="toggle-order" style="display: none">{{ text_showorder }}<i class="fa fa-angle-down"></i></div>
                </div>
                {#订单结算#}
                <div class="order-count">
                    <div class="freight">
                        <span>{{ text_freight }}</span>
                        <span class="data">{{ getSymbolLeft }}0.00</span>
                    </div>
                    <div class="money">
                        <span>{{ text_allmoney }}</span>
                        <span class="data">{% if not special %}{{ price }}{% else %}{{ special }}{% endif %}</span>
                    </div>
                    <div class="count">
                        <span>{{ text_moneys }}</span>
                        <span class="data" style="color: #ff5a5f;font-weight: bold;">{% if not special %}{{ price }}{% else %}{{ special }}{% endif %}</span>
                    </div>
                </div>
                {{ confirm }}
                {#底部承诺#}
                <div class="promise">
                    <div><i class="iconfont icon-qitian"></i>{{ text_seven }}</div>
                    <div><i class="iconfont icon-mianfei"></i>{{ text_cash_on_delivery }}</div>
                </div>
            </div>
            {#商品详情页面#}
            <div id="productInfo">
                {#轮播#}
                <div id="goods-img-banner" class="swiper-container">
                    <ul class="swiper-wrapper" style="list-style: none;padding: 0;">
                        <li class="swiper-slide text-center">
                            <a class="thumbnail goods-img" href="javascript:" title="{{ heading_title }}">
                                <img src="{{ popup }}" alt="{{ heading_title }}" class="img-responsive"/>
                            </a>
                        </li>
                        {% for image in images %}
                            <li class="swiper-slide text-center">
                                <a class="thumbnail goods-img" href="javascript:" title="{{ heading_title }}">
                                    <img src="{{ image.popup }}" alt="{{ heading_title }}" class="img-responsive"/>
                                </a>
                            </li>
                        {% endfor %}
                    </ul>
                    {#<div class="swiper-pagination slideshow-point"></div>#}
                </div>
                <script type="text/javascript">
                    var options = {
                        mode: 'horizontal',
                        slidesPerView: 1,
                        pagination: '.slideshow-point',
                        paginationClickable: true,
                        autoplay: 2500,
                        autoplayDisableOnInteraction: true,
                    };
                    if($('#goods-img-banner .swiper-wrapper').find('.swiper-slide').length > 1){
                        $('#goods-img-banner').append('<div class="swiper-pagination slideshow-point"></div>');
                        options.loop = true;
                    }
                    $('#goods-img-banner').swiper(options);
                </script>
                {#商品名称#}
                <h2>{{ heading_title }}</h2>
                {#好评率#}
                <div class="praises">
                    <div style="margin-right: 10px;">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                    </div>
                    <div>96%</div>
                    <div>{{ text_praises }}</div>
                </div>
                {#价格#}
                <div class="product-price">
                    <div class="price-box">
                        {% if not special %}
                            <h3>{{ price }}</h3>
                        {% else %}
                            <del class="special">{{ price }} </del>
                            <span class="gree">{{ saveoff }}% {{ text_special }}</span>
                            <h3>{{ special }}</h3>
                        {% endif %}
                    </div>
                </div>
                {#销量进度条#}
                <div class="progress-box">
                    <div class="product-progress">
                        {#100 - (銷量/庫存*100)#}
                        <div class="progress-color" style="left: -{{ 100-(sales_volume/quantity*100) }}%"></div>
                        {#<span>{{ product.sales_volume }} SOLD</span>#}
                    </div>
                    {{ text_only }} {{ quantity - sales_volume }} {{ text_pieces }}
                </div>
                {#选择规格#}
                <div id="getAttr" class="get-attr">
                    <div>Choose parameter</div>
                    <i class="fa fa-chevron-right"></i>
                </div>
                {#查询订单#}
                <div class="query-box">
                    <div class="query" id="toQuery">
                        <i class="fa fa-circle"></i>
                        <span>{{ text_query }}</span>
                    </div>
                    <div class="reviews" id="toReviews">
                        <i class="fa fa-circle"></i>
                        <span>{{ text_reviews }}</span>
                    </div>
                </div>
                {#導航#}
                <div class="menu" id="nav">
                    <div style="height: 40px;">
                        <img style="vertical-align: top" src="catalog/view/theme/default/image/leaf.png">
                        <span style="line-height: 40px;font-size: 15px;color: #fff">{{ tab_description }}</span>
                    </div>
                    <div style="height: 40px;line-height: 40px;padding-right: 30px;">
                        <img src="catalog/view/theme/default/image/kefu.png" style="height: 60%;">
                    </div>
                </div>
                {#商品详情#}
                <div class="description" id="goods-info">
                    {{ magevideo }}
                </div>
                {#用戶須知#}
                {#<div class="user-know">#}
                    {#<div class="know-title">{{ text_know }}</div>#}
                    {#<div class="user-know-title">#}
                        {#1.เงื่อนไขเปลี่ยนคืนสินค้า#}
                    {#</div>#}
                    {#<ul class="user-know-content">#}
                        {#<li>สินค้าที่รับเปลี่ยนหรือคืน หลังจะได้รับสินค้า （นับจักวันที่เซนรับสินค้า）ภายใน 7 วัน ติดต่อทาง E-MAILว่าจะเปลี่ยนหรือคืนสิน ถ้าเกิน7วันจะไม่สามารถทำการเปลี่ยนคืนแล้วค่ะ</li>#}
                        {#<li>สินค้าที่จะเปลี่ยนคืน กรุณาอย่าใช้และกรุณาการเก็บรักษาสินค้าให้สอาดเรียบร้อย</li>#}
                        {#<li>กรุณาการเก็บรักษาอุปกรณ์เสริมและเอกสารของสินค้าต่างๆให้ครบเรียบ（เช่น การระบุผลิตภัณฑ์ บรรจุภัณฑ์ แท็กสินค้า ใบรับประกันสินค้า คู่มือ ใบเสร็จ ของแถม อุปกรณ์เสริม ใบรับรองสินค้า）</li>#}
                    {#</ul>#}
                    {#<div class="user-know-title">#}
                        {#2.ถ้าสินค้าที่เปลี่ยนคืนมีตำหนิตามข้อกำหนดข้างล้างนี้ ถือว่าเป็นสินค้าที่มีผลกระทบต่อการขายครั้งที่สอง ไม่สามารถเปลี่ยนคืนได้#}
                    {#</div>#}
                    {#<ul class="user-know-content">#}
                        {#<li>ถ้าสินค้าที่ทำให้เสียโฉม ความแตกแยกและเสียหายที่ไม่เหมือนของใหม่</li>#}
                        {#<li>ขาดของแถม อุปกรณ์เสริม และแทกขาดเสียหาย</li>#}
                        {#<li>การใช้สินค้าไม่เหมาะสมและการรักษาไม่ดีที่ทำให้คุณภาพสินค้าต่ำลง</li>#}
                        {#<li>การใช้งานสินค้า การซัก ขีดฆ่า และแตกแยก ๆๆ</li>#}
                        {#<li>การซ่อมสินค้าที่ไม่ได้รับอนุญาต การใช้งานไม่ถูกต้อง การชนกัน การใช้ผิดวิธี ไม่ระวางการใช้งาน โดนของเหลวเข้า อุบัติเหตุ การเปลี่ยนแปลงสินค้า และการใส่สินค้าที่ไม่ถูกวิธีการใช้ที่ทำให้สินค้าเกิดปัญหาที่เกียวกับคุณภาพ หรือฉีกขาดแท็ก ขีดฆ่าแท็กการ หมายเลขสินค้า และเครื่องหมายต่อต้านการปลอมแปลง</li>#}
                        {#<li>สินค้าแตกหาก สูญเสียจากการใช้งาน</li>#}
                    {#</ul>#}
                    {#<div class="user-know-title">#}
                        {#3.เงื่อนไขคืนเงิน#}
                    {#</div>#}
                    {#<ul class="user-know-content">#}
                        {#<li>เหตุผลส่วนตัวที่ต้องเปลี่ยนคืนสินค้า ต้องขอโทษและขออภัยด้วยคุณลูกค้าต้องเสียค่าขนส่ง300บาท เอง</li>#}
                        {#<li>ถ้าเกิดปัญหาจากความบกพร่องในตัวสินค้า ทางเรายินดีเปลี่ยนสินค้าให้คุณลูกค้า หรือว่าคืนสินค้า และ ทางเราจะรับผิดชอบค่าจัดส่งเอง</li>#}
                    {#</ul>#}
                    {#<div class="user-know-title">#}
                        {#4.เคล็ดลับพิเศษ#}
                    {#</div>#}
                    {#<ul class="user-know-content">#}
                        {#<li>รูปภาพและข้อมูลใช้สำหรับการอ้างอิงเท่านั้น เนื่องจากปัญหาต่างๆเช่นไฟกระพริบและความผิดเพี้ยนของสีของจอภาพที่ต่างกันอาจมีความแตกต่างของสีระหว่างภาพผลิตภัณฑ์และผลิตภัณฑ์จริง โปรดเข้าใจว่านี่ไม่ใช่ปัญหาด้านคุณภาพ</li>#}
                        {#<li>รายการกำลังขายอย่างแน่นหนา สไตล์และสีคือการจัดส่งแบบสุ่ม โปรดเข้าใจว่านี่ไม่ใช่ปัญหาด้านคุณภาพ</li>#}
                    {#</ul>#}
                {#</div>#}
                {#底部购买栏#}
                <div class="bottom-btn">
                    {{ button_buy }}
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="home_date_now" value="{{ date_now }}">
    <input type="hidden" id="home_date_end" value="{{ date_end }}">
    <input type="hidden" id="max_buy" value="{{ maxnum }}">
</div>
<script>
    $(function () {
        countdown($('#home_date_now').val(), $('#home_date_end').val());
        hideD();
        haveMore();
        videoWidth();
    });
    // 视频标签自适应宽度
    function videoWidth() {
        $('.description').find('video').attr('width','100%;');
    }
    // 判斷是否有贈品
    function haveMore() {
        {#var have = '{{ text_allnum }}<span id="countNumber" data-num="1">2</span>，{{ text_giving }}<span>1</span>gift';#}
        {#var haveNot = '{{ text_allnum }}<span id="countNumber" data-num="0">1</span>';#}
        {#if($('input[name=haveMore]').val() == undefined){#}
            {#$('#haveMoreDom').html(haveNot);#}
        {#}else {#}
            {#$('#haveMoreDom').html(have);#}
        {#}#}
    }

    // 倒计时
    function countdown(startTime, endTime) {
        var allTime = endTime - startTime;
        var timer = setInterval(function () {
            if (allTime <= 0) {
                $('#countdown').empty();
                clearInterval(timer);
                return false;
            }
            var h = Math.floor(allTime / 3600);
            var m = Math.floor((allTime % 3600) / 60);
            var s = (allTime % 3600) % 60;
            if (h > 99) {
                h = 99;
            }
            if (h < 10) {
                h = '0' + h;
            }
            if (m < 10) {
                m = '0' + m;
            }
            if (s < 10) {
                s = '0' + s;
            }
            var tag = '{{ text_flash_sale }}<span class="kill-number">' + h + '</span>{{ text_hour }}<span class="kill-number">' + m + '</span>{{ text_minute }}<span class="kill-number">' + s + '</span>{{ text_second }}';
            $('#countdown').html(tag);
            allTime--;
        }, 1000)
    }
    // 吸頂
    var goodsTitleTop = $('#nav').offset().top;
    window.onscroll = function () {
        if ($(window).scrollTop() >= goodsTitleTop) {
            $('#nav').addClass('position-fixed');
            $('#goods-info').css('margin-top', '36px');
        } else {
            $('#nav').removeClass('position-fixed');
            $('#goods-info').css('margin-top', '0');
        }
    };


</script>
<script>
    // 点击查询订单
    $('#toQuery').on('click', function () {
        window.location.href = '/query.html'
    });
    // 点击选择规格
    $('#getAttr').on('click',function () {
        $('.bottom-btn').click();
    })
    // 提交订单
    $('.bottom-btn').on('click', function () {
        $(window).scrollTop(0);
        $('#product').animate({'left': '0'}, 200, function () {
            $('#product').siblings('#productInfo').hide();
        });
    });
    // 关闭规格页面
    $('#closeProduct').on('click', function () {
        $('#product').siblings('#productInfo').show();
        $('#product').animate({'left': '3000px'}, 200);
    });
    // 点击购物车页返回首页
    $('#backHome').on('click',function () {
        $('.radio-selected').removeClass('radio-selected').find('input').removeAttr('checked');
        $('#product').siblings('#productInfo').show();
        $('#productOrder').animate({'top':'-2000px'},200,function () {
            $('#product').animate({'left':'3000px'},200);
        });
    });
    // 购物车页面表单聚焦去除红框
    $('#collapse-payment-address input').on('focus', function () {
        $(this).removeClass('has-error');
    });
    // 点击购物车页面商品显示/隐藏更多信息
    $('.toggle-order').on('click', function () {
        if($(this).children('i').hasClass('fa-angle-down')){
            $('.hide-order').slideDown(300);
            $(this).children('i').addClass('fa-angle-up').removeClass('fa-angle-down');
        }else {
            $('.hide-order').slideUp(300);
            $(this).children('i').addClass('fa-angle-down').removeClass('fa-angle-up');
        }
    });
</script>
<script>
    // // 点赞
    $('#getLikeA').on('click', function () {
        // console.log($('#getLikea').find('iframe')[0].contentWindow);
    });
    // 点击蒙板空白区域
    $('.mask').on('click', function () {
        $('body').css('overflow', 'visible');
        $('.product-header').css('z-index', '0');
        $('.mask').stop().hide();
        $('.more-list').stop().slideUp(100);
        $('.coupons-module').stop().slideUp(300);
        $('#product').stop().slideUp(300);
        $('.integral-module').stop().slideUp(300);
        $('#form-review').stop().slideUp(300);
        $('.commitment-module').stop().slideUp(300);
    });
    // 评论蒙板
    $('#writeMessage').on('click', function () {
        $('.mask').stop().show();
        $('#form-review').stop().slideDown(300);
        $('body').css('overflow', 'hidden');
        $('#product-product #form-review .stars').html(
            '<label><span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span><input type="radio" name="rating" value="1"/></label>' +
            '<label><span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span><input type="radio" name="rating" value="2"/></label>' +
            '<label><span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span><input type="radio" name="rating" value="3"/></label>' +
            '<label><span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span><input type="radio" name="rating" value="4"/></label>' +
            '<label><span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span><input type="radio" name="rating" value="5"/></label>'
        );
    });
    $('.close-write').on('click', function () {
        $('.mask').stop().hide();
        $('#form-review').stop().slideUp(300);
        $('body').css('overflow', 'visible');
    });


    // 选择规格
    $('#product-product #product .newRadio .radio-box .radio').on('click', function () {
        $(this).siblings().find('label').removeClass('radio-selected');
        $(this).find('label').addClass('radio-selected');
        if ($(this).parents('.newRadio').prev().hasClass('option-header')) {
            $(this).parents('.newRadio').prev().attr('data-id' + $(this).parent().attr('id').replace('input-option', ''), $(this).text().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))
            // $(this).parents('.newRadio').prev().find('.selecting').text(getValue($(this).parents('.newRadio').prev()[0].dataset))
        } else {
            $(this).parents('.newRadio').prevUntil('.option-header').prev().attr('data-id' + $(this).parent().attr('id').replace('input-option', ''), $(this).text().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))
            // $(this).parents('.newRadio').prevUntil('.option-header').prev().find('.selecting').text(getValue($(this).parents('.newRadio').prevUntil('.option-header').prev()[0].dataset))
        }
        $(this).parents('.radio-box').siblings('label').children('.selecting').html($(this).find('.option-name').text());
        $(this).parents('.newRadio').css({'border':'none'});
        if($(this)[0].dataset.isfirst !== undefined){
            $('.orderMeal').text($(this).find('.option-name').text())
        }
        if($(this)[0].dataset.name.substr($(this)[0].dataset.name.length-3) === '$$$'){
            var initPrice = Number($('#initPrice').text().replace(/[^\d.]/g,''));
            var moneyType = $('#initPrice').text().replace(/[\d.,]/g,'');
            var changeType = $(this)[0].dataset.changetype;
            var changeNum = Number($(this)[0].dataset.changenum.replace(/[^\d.]/g,''));
            var multiple = $('input[name=quantity]').val();
            var res = '';
            if(changeType == '+'){
                res = initPrice + changeNum;
            }else if(changeType == '-'){
                res = initPrice - changeNum;
            }
            $('#hiddenorder-money').val(res);
            res = res * multiple;
            res = res.toFixed(2);
            if('{{ getSymbolLeft }}'){
                res = moneyType + res;
            }else if('{{ getSymbolRight }}'){
                res = res + moneyType
            }
            $('#countPrice').text(res);
        }
    });
    $('#product-product #product .newRadio .radio-box .img-radio').on('click', function () {
        $(this).siblings().find('label').removeClass('radio-selected');
        $(this).find('label').addClass('radio-selected');
        if ($(this).parents('.newRadio').prev().hasClass('option-header')) {
            $(this).parents('.newRadio').prev().attr('data-id' + $(this).parent().attr('id').replace('input-option', ''), $(this).text().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))
            // $(this).parents('.newRadio').prev().find('.selecting').text(getValue($(this).parents('.newRadio').prev()[0].dataset))
        } else {
            $(this).parents('.newRadio').prevUntil('.option-header').prev().attr('data-id' + $(this).parent().attr('id').replace('input-option', ''), $(this).text().replace(/^\s\s*/, '').replace(/\s\s*$/, ''))
            // $(this).parents('.newRadio').prevUntil('.option-header').prev().find('.selecting').text(getValue($(this).parents('.newRadio').prevUntil('.option-header').prev()[0].dataset))
        }
        $(this).parents('.radio-box').siblings('label').children('.selecting').html($(this).find('.option-name').text());
        $(this).parents('.newRadio').css({'border':'none'});
        $('.orderImg').attr('src', $(this).find('img').attr('src'));
        if($(this)[0].dataset.name.substr($(this)[0].dataset.name.length-3) === '$$$'){
            var initPrice = Number($('#initPrice').text().replace(/[^\d.]/g,''));
            var moneyType = $('#initPrice').text().replace(/[\d.,]/g,'');
            var changeType = $(this)[0].dataset.changetype;
            var changeNum = Number($(this)[0].dataset.changenum.replace(/[^\d.]/g,''));
            var multiple = $('input[name=quantity]').val();
            var res = '';
            if(changeType == '+'){
                res = initPrice + changeNum;
            }else if(changeType == '-'){
                res = initPrice - changeNum;
            }
            $('#hiddenorder-money').val(res);
            res = res * multiple;
            res = res.toFixed(2);
            if('{{ getSymbolLeft }}'){
                res = moneyType + res;
            }else if('{{ getSymbolRight }}'){
                res = res + moneyType
            }
            $('#countPrice').text(res);
        }
    });
    {#function getValue(data) {#}
        {#var result = '{{ text_selected }}';#}
        {#for (var i in data) {#}
            {#result += data[i] + ' ';#}
        {#}#}
        {#return result;#}
    {#}#}
    // 隱藏$$$
    function hideD() {
        var dom = $('.optionName');
        for (var i = 0; i < dom.length; i++) {
            if($(dom[i]).text().substr($(dom[i]).text().length-3) === '$$$' || $(dom[i]).text().substr($(dom[i]).text().length-3) === '###'){
                $(dom[i]).text($(dom[i]).text().slice(0, $(dom[i]).text().length-3))
            }
        }
    }
    // 加减
    var ordermoney = $('#countPrice');
    var getSymbolLeft = '{{ getSymbolLeft }}';
    var getSymbolRight = '{{ getSymbolRight }}';
    var maxBuy = $('#max_buy').val();
    $('#minus').on('click', function () {
        var hiddenorder = Number($('#hiddenorder-money').val());
        var count = $('#product-product #product .buy-count .change-number input[name=quantity]').val();
        count--;
        if (count <= 1) {
            count = 1;
        }
        $('#product-product #product .buy-count .change-number input[name=quantity]').val(count);
        // $('#countNumber').text(count + parseInt($('#countNumber')[0].dataset.num));
        $('#countNumber').text(count);
        if (getSymbolRight) {
            ordermoney.text((hiddenorder * count).toFixed(2) + getSymbolRight);
        } else if (getSymbolLeft) {
            ordermoney.text(getSymbolLeft + (hiddenorder * count).toFixed(2));
        } else {
            ordermoney.text((hiddenorder * count).toFixed(2));
        }
    });
    $('#plus').on('click', function () {
        var hiddenorder = Number($('#hiddenorder-money').val());
        var count = $('#product-product #product .buy-count .change-number input[name=quantity]').val();
        count++;
        if(maxBuy !== ''){
            if (count > maxBuy) {
                $('#tipModule').text('The  product purchase restrictions'+ maxBuy + 'pieces！').show();
                setTimeout(function () {
                    $('#tipModule').text('').hide();
                }, 1500);
                count = maxBuy;
                return false;
            }
        }
        $('#product-product #product .buy-count .change-number input[name=quantity]').val(count);
        // $('#countNumber').text(count + parseInt($('#countNumber')[0].dataset.num));
        $('#countNumber').text(count);
        if (getSymbolRight) {
            ordermoney.text((hiddenorder * count).toFixed(2) + getSymbolRight);
        } else if (getSymbolLeft) {
            ordermoney.text(getSymbolLeft + (hiddenorder * count).toFixed(2));
        } else {
            ordermoney.text((hiddenorder * count).toFixed(2));
        }
    });
    // 【限時特惠】再來兩件，僅需NT$300
    $('.more-btn').on('click', function () {
        //$('#plus').click();
    });
    // 選擇評論的星星數
    $('#product-product #form-review .stars').on('click', 'input[name=rating]', function () {
        var value = $('#product-product #form-review .stars input[name=rating]:checked').val();
        var unselect = '<span class="star fa fa-stack"><i class="star fa fa-star-o fa-stack-1x"></i></span>';
        var selected = '<span class="star fa fa-stack"><i class="star fa fa-star fa-stack-1x"></i><i class="star fa fa-star-o fa-stack-1x"></i></span>'
        var tag = '';
        for (var i = 1; i <= 5; i++) {
            tag += '<label>';
            if (i <= value) {
                tag += selected;
            } else {
                tag += unselect;
            }
            if (i == value) {
                tag += '<input type="radio" name="rating" checked value="' + i + '"/>';
            } else {
                tag += '<input type="radio" name="rating" value="' + i + '"/>';
            }
            tag += '</label>';
        }
        $('#product-product #form-review .stars').html(tag);
    });
    // 点击评论滚动页面
    $('#toComments').on('click', function () {
        $('html,body').stop().animate({scrollTop: $('#message')[0].offsetTop}, 500);
    })
    // 複製折扣碼
    $('.copyCode').on('click', function () {
        var dom = $(this).siblings('.codeIn').find('input')[0];
        dom.select();
        document.execCommand("Copy");
        $('#tipModule').text('複製成功！').show();
        setTimeout(function () {
            $('#tipModule').text('').hide();
        }, 1500);
        $('.coupons-footer').click();
    })
</script>
<script type="text/javascript"><!--
    $('select[name=\'recurring_id\'], input[name="quantity"]').change(function () {
        $.ajax({
            url: 'index.php?route=product/product/getRecurringDescription',
            type: 'post',
            data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
            dataType: 'json',
            beforeSend: function () {
                $('#recurring-description').html('');
            },
            success: function (json) {
                $('.alert-dismissible, .text-danger').remove();

                if (json['success']) {
                    $('#recurring-description').html(json['success']);
                }
            }
        });
    });
    //--></script>
<script type="text/javascript"><!--
    $('#button-cart').on('click', function () {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
            dataType: 'json',
            beforeSend: function () {
                $('#button-cart').button('loading');
            },
            complete: function () {
                $('#button-cart').button('reset');
            },
            success: function (json) {
                $('.alert-dismissible, .text-danger').remove();
                $('.form-group').removeClass('has-error');

                if (json['error']) {
                    if (json['error']['option']) {
                        for (i in json['error']['option']) {
                            var element = $('#input-option' + i.replace('_', '-'));

                            if (element.parent().hasClass('input-group')) {
                                element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                            } else {
                                element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                            }
                        }
                    }

                    if (json['error']['recurring']) {
                        $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
                    }
                    if (json['error']['hasadd']) {
                        alert('您已添加該產品');
                    }

                    // Highlight any found errors
                    $('.text-danger').parent().addClass('has-error');
                }

                if (json['success']) {
                    $('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                    $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

                    $('html, body').animate({scrollTop: 0}, 'slow');
                    window.location.href = "checkout_cart.html";
                    $('#cart > ul').load('index.php?route=common/cart/info ul li');
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    });
    //--></script>
<script type="text/javascript"><!--
    $('.date').datetimepicker({
        language: '{{ datepicker }}',
        pickTime: false
    });

    $('.datetime').datetimepicker({
        language: '{{ datepicker }}',
        pickDate: true,
        pickTime: true
    });

    $('.time').datetimepicker({
        language: '{{ datepicker }}',
        pickDate: false
    });

    $('button[id^=\'button-upload\']').on('click', function () {
        var node = this;

        $('#form-upload').remove();

        $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

        $('#form-upload input[name=\'file\']').trigger('click');

        if (typeof timer != 'undefined') {
            clearInterval(timer);
        }

        timer = setInterval(function () {
            if ($('#form-upload input[name=\'file\']').val() != '') {
                clearInterval(timer);

                $.ajax({
                    url: 'index.php?route=tool/upload',
                    type: 'post',
                    dataType: 'json',
                    data: new FormData($('#form-upload')[0]),
                    cache: false,
                    contentType: false,
                    processData: false,
                    beforeSend: function () {
                        $(node).button('loading');
                    },
                    complete: function () {
                        $(node).button('reset');
                    },
                    success: function (json) {
                        $('.text-danger').remove();

                        if (json['error']) {
                            $(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            alert(json['success']);

                            $(node).parent().find('input').val(json['code']);
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            }
        }, 500);
    });
    //--></script>
<script type="text/javascript"><!--
    $('#review').delegate('.pagination a', 'click', function (e) {
        e.preventDefault();

        $('#review').fadeOut('slow');

        $('#review').load(this.href);

        $('#review').fadeIn('slow');
    });

    $('#review').load('index.php?route=product/product/review&product_id={{ product_id }}');

    $('#button-review').on('click', function () {
        $.ajax({
            url: 'index.php?route=product/product/write&product_id={{ product_id }}',
            type: 'post',
            dataType: 'json',
            data: $("#form-review").serialize(),
            beforeSend: function () {
                $('#button-review').button('loading');
            },
            complete: function () {
                $('#button-review').button('reset');
                $('.mask').click();
            },
            success: function (json) {
                $('.alert-dismissible').remove();

                if (json['error']) {
                    $('#tipModule').text(json['error']).show();
                    setTimeout(function () {
                        $('#tipModule').text('').hide();
                    }, 1500);
                    // $('#review').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                }

                if (json['success']) {
                    $('#tipModule').text(json['success']).show();
                    setTimeout(function () {
                        $('#tipModule').text('').hide();
                    }, 1500);
                    // $('#review').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                    $('input[name=\'name\']').val('');
                    $('textarea[name=\'text\']').val('');
                    $('input[name=\'rating\']:checked').prop('checked', false);
                }
            }
        });
    });

    $(document).ready(function () {
        $('.thumbnails').magnificPopup({
            type: 'image',
            delegate: 'a',
            gallery: {
                enabled: true
            }
        });
    });


    $(function () {

        $(".praise").click(function () {

            var praise = $(this);

            var product_id = praise.attr("rel"); //获取HTML页面POST过来的article_id

            var cat_id = praise.attr("rev"); //获取HTML页面POST过来的cat_id

            $.ajax({

                type: "POST",

                url: "{{ praiseurl }}",

                data: "product_id=" + product_id + "&cat_id=" + cat_id,//数据拼接

                cache: false, //不缓存此页面

                success: function (data) {
                    if (data.mesage == '點贊成功') {
                        praise.html('<i class="iconfont icon-zan">贊</i>' + data.num); //显示data并局部刷新
                        alert(data.mesage);
                    } else {

                        alert(data.mesage);
                    }


                },
                error: function () {

                    alert("error");

                }

            });

        });

    });
    //--></script>

{#-----------------------------------------------#}
<script type="text/javascript"><!--
    $('#toCart').on('click',function () {
        $('#productOrder input[name]').val('');
        cartAddBefore();
    });
    $('#button-confirm').on('click', function () {
        guestsavehebing();
    });
    function cartAddBefore() {
        var list = $('.newRadio');
        var attrArr = [];
        for (var i = 0; i < list.length; i++) {
            $(list[i]).css({'border':'none'});
            if($(list[i]).find('input[type="radio"]:checked').length == 0){
                $(list[i]).css({'border':'2px solid #eb2455'});
                alert('{{ text_errorData }}');
                return false;
            }
            attrArr.push($(list[i]).find('.selecting').text());
        }
        // attrArr.shift();
        var attrDom = '<span>';
        attrDom += attrArr.join('</span><span>');
        attrDom += '</span>'
        $('.orderAttr').html(attrDom);
        $('#productOrder').animate({'top': '0'}, 200);
    }
    function cartadd() {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea,  #productOrder input[type=\'text\'], #productOrder input[type=\'hidden\'], #productOrder input[type=\'radio\']:checked, #productOrder input[type=\'checkbox\']:checked, #productOrder select, #productOrder textarea'),
            dataType: 'json',
            beforeSend: function () {
                //$("#button-confirm-mobile").attr('disabled',true);
                $("#button-confirm").attr('disabled', true);
            },
            complete: function () {
                //$("#button-confirm-mobile").attr('disabled',false);

            },
            success: function (json) {
                console.log(json);

                $('.alert-dismissible, .text-danger').remove();
                $('.form-group').removeClass('has-error');

                if (json['error']) {
                    if (json['error']['option']) {
                        var elementnoteop = '';
                        for (i in json['error']['option']) {
                            var element = $('#input-option' + i.replace('_', '-'));
                            var elements = $('#input-options' + i.replace('_', '-'));
                            if (!elementnoteop) {
                                elementnoteop = element;
                                if (element.parent().hasClass('input-group')) {
                                    // if ($(element).parent().children().hasClass('text-danger')) {
                                        $('.text-danger').remove();
                                    // }
                                    element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                                    $('#tipModule').text(json['error']['option'][i]).show();
                                    setTimeout(function () {
                                        $('#tipModule').text('').hide();
                                    }, 1500);
                                    // window.location.hash = "#" + elements.attr("id");
                                    $(window).scrollTop(element.offset().top - 80);
                                } else {
                                    // if ($(element).parent().children().hasClass('text-danger')) {
                                        $('.text-danger').remove();
                                    // }
                                    element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                                    $('#tipModule').text(json['error']['option'][i]).show();
                                    setTimeout(function () {
                                        $('#tipModule').text('').hide();
                                    }, 1500);
                                    // window.location.hash = "#" + elements.attr("id");
                                    $(window).scrollTop(element.offset().top - 80);
                                }


                            }


                        }

                        $("#button-confirm").attr('disabled', false);
                    }

                    if (json['error']['recurring']) {
                        $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
                    }

                    // Highlight any found errors
                    $('.text-danger').parent().addClass('has-error');
                }

                if (json['success']) {

                    confirmhe();

                    //$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

                    //$('html, body').animate({ scrollTop: 0 }, 'slow');

                    //$('#cart > ul').load('index.php?route=common/cart/info ul li');
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });


    }

    function confirmhe() {
        $.ajax({
            url: 'index.php?route=checkout/confirm_he',
            dataType: 'html',
            beforeSend: function () {
                //$("#button-confirm-mobile").attr('disabled',true);
                $("#button-confirm").attr('disabled', true);
            },
            complete: function () {
                //$("#button-confirm-mobile").attr('disabled',false);

            },
            success: function (html) {
                //$('#collapse-checkout-confirm .panel-body').html(html);

                //$('#button-confirm').on('click', function() {
                $.ajax({
                    url: 'index.php?route=extension/payment/cod/confirm',
                    dataType: 'json',
                    beforeSend: function () {
                        //$("#button-confirm-mobile").attr('disabled',true);
                        $("#button-confirm").attr('disabled', true);
                    },

                    success: function (json) {
                        if (json['redirect']) {
                            location = json['redirect'];
                        }
                        //$("#button-confirm").attr('disabled',false);
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
                //});

            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                $("#button-confirm").attr('disabled', false);
            }
        });
        ///////
    }

    function guestsavehebing() {
        var country = $('#input-payment-country'),
            zone = $('#input-payment-zone'),
            district = $('#input-payment-district'),
            mukim = $('#input-payment-mukim');
        if(country.val() == ''){
            country.addClass('has-error');
            $('#tipModule').text('Please select a State').show();
            setTimeout(function () {
                $('#tipModule').text('').hide();
            }, 1500);
            $('#productOrder').scrollTop(country[0].offsetTop);
            return;
        }
        if(zone.val() == ''){
            zone.addClass('has-error');
            $('#tipModule').text('Please select a City').show();
            setTimeout(function () {
                $('#tipModule').text('').hide();
            }, 1500);
            $('#productOrder').scrollTop(zone[0].offsetTop);
            return;
        }
        if(district.val() == ''){
            district.addClass('has-error');
            $('#tipModule').text('Please select a District').show();
            setTimeout(function () {
                $('#tipModule').text('').hide();
            }, 1500);
            $('#productOrder').scrollTop(district[0].offsetTop);
            return;
        }
        if(mukim.val() == ''){
            mukim.addClass('has-error');
            $('#tipModule').text('Please select a Mukim').show();
            setTimeout(function () {
                $('#tipModule').text('').hide();
            }, 1500);
            $('#productOrder').scrollTop(mukim[0].offsetTop);
            return;
        }
        $.ajax({
            url: 'index.php?route=checkout/guest/savehebing',
            type: 'post',
            data: $('#collapse-payment-address input[type=\'text\'], #collapse-payment-address input[type=\'date\'], #collapse-payment-address input[type=\'datetime-local\'], #collapse-payment-address input[type=\'time\'], #collapse-payment-address input[type=\'checkbox\']:checked, #collapse-payment-address input[type=\'radio\']:checked, #collapse-payment-address input[type=\'hidden\'], #collapse-payment-address textarea, #collapse-payment-address select'),
            dataType: 'json',
            beforeSend: function () {
                //$("#button-confirm-mobile").attr('disabled',true);
                $("#button-confirm").attr('disabled', true);
            },
            complete: function () {
                //$("#button-confirm-mobile").attr('disabled',false);

            },
            success: function (json) {
                console.log(json);
                if (json['redirect']) {
                    location = json['redirect'];
                } else if (json['error']) {
                    $('#collapse-payment-address input').removeClass('has-error');
                    var elementnoteo = '';
                    for (var i in json['error']) {
                        var element = $('#input-payment-' + (i === 'country' ? 'postcode' : i).replace('_', '-'));
                        element.addClass('has-error');

                        $('#tipModule').text(json['error'][i]).show();
                        setTimeout(function () {
                            $('#tipModule').text('').hide();
                        }, 1500);

                        $('#productOrder').scrollTop(element[0].offsetTop);
                        $("#button-confirm").attr('disabled', false);
                        return false;
                        // if (!elementnoteo) {
                        //     elementnoteo = element;
                        //
                        //     $('.has-error').removeClass('has-error');
                        //     $('.text-danger').remove();
                        //     $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');

                            // if ($(element).parent().hasClass('input-group')) {
                            //     // if ($(element).parent().children().hasClass('text-danger')) {
                            //         $('.text-danger').remove();
                            //     // }
                            //     $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
                            // } else {
                            //     // if ($(element).parent().children().hasClass('text-danger')) {
                            //         $('.text-danger').remove();
                            //     // }
                            //     $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
                            // }


                        // }


                    }
                    // window.location.hash = "#" + elementnoteo.attr("id");

                    // Highlight any found errors
                    // $('.text-danger').prev().addClass('has-error');
                } else {


                    cartadd();


                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });

    }


    //--></script>

{#{{ footer }}#}
